/*
 * Copyright (C) 2011-2016 Markus Junginger, greenrobot (http://greenrobot.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.greenrobot.greendao;

import java.util.List;

import org.greenrobot.greendao.internal.TableStatements;

import ohos.data.resultset.ResultSet;

/** For internal use by greenDAO only. */
public final class InternalQueryDaoAccess<T> {
    private final AbstractDao<T, ?> dao;

    /**
     * Constructor
     * @param abstractDao abstractDao
     */
    public InternalQueryDaoAccess(AbstractDao<T, ?> abstractDao) {
        dao = abstractDao;
    }

    /**
     * Load the current from cursor
     * @param cursor cursor
     * @param offset offset
     * @param lock lock
     * @return entity or dao
     */
    public T loadCurrent(ResultSet cursor, int offset, boolean lock) {
        return dao.loadCurrent(cursor, offset, lock);
    }

    /**
     * load all entities and close cursor
     * @param cursor cursor
     * @return list of entities or dao
     */
    public List<T> loadAllAndCloseCursor(ResultSet cursor) {
        return dao.loadAllAndCloseCursor(cursor);
    }

    /**
     * Load unique and close cursor
     * @param cursor cursor
     * @return entitiy
     */
    public T loadUniqueAndCloseCursor(ResultSet cursor) {
        return dao.loadUniqueAndCloseCursor(cursor);
    }

    /**
     * Get statements
     * @return table statements
     */
    public TableStatements getStatements() {
        return dao.getStatements();
    }

    /**
     * Get statements from dao
     * @param dao dao
     * @param <T2> generic dao
     * @return abstract dao
     */
    public static <T2> TableStatements getStatements(AbstractDao<T2, ?> dao) {
        return dao.getStatements();
    }

}